﻿using System.IO;
using System.Windows.Forms;
using log4net;
using System.Collections.Generic;
using System.Collections;
using System.Drawing;

namespace RollBack.src.ui
{
    partial class ExplorerRightPanel
    {
        private static ILog log = LogManager.GetLogger(typeof(ExplorerRightPanel));
        /// <summary> 
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        public List<ListViewItem> m_backupList {
            get;
            set;
        }
        

        public List<ListViewItem> m_restoreList {
            get; 
            set; 
        }


        /// <summary> 
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Component Designer generated code

        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent( )
        {
            this.FileName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
            this.Extension = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
            this.Modified = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
            this.FileSize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
            this.m_fileListView = new System.Windows.Forms.ListView();
            this.SuspendLayout();
            // 
            // FileName
            // 
            this.FileName.Text = "Name";
            this.FileName.Width = 320;
            // 
            // Extension
            // 
            this.Extension.Text = "Extn";
            // 
            // Modified
            // 
            this.Modified.DisplayIndex = 3;
            this.Modified.Text = "Modified";
            this.Modified.Width = 160;
            // 
            // FileSize
            // 
            this.FileSize.DisplayIndex = 2;
            this.FileSize.Text = "Size";
            this.FileSize.Width = 80;
            // 
            // m_fileListView
            // 
            this.m_fileListView.AllowDrop = true;
            this.m_fileListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
            this.FileName,
            this.Extension,
            this.Modified,
            this.FileSize});
            this.m_fileListView.Dock = System.Windows.Forms.DockStyle.Fill;
            this.m_fileListView.FullRowSelect = true;
            this.m_fileListView.GridLines = true;
            this.m_fileListView.Location = new System.Drawing.Point(0, 0);
            this.m_fileListView.Name = "m_fileListView";
            this.m_fileListView.Size = new System.Drawing.Size(440, 156);
            this.m_fileListView.TabIndex = 0;
            this.m_fileListView.UseCompatibleStateImageBehavior = false;
            this.m_fileListView.View = System.Windows.Forms.View.Details;
            this.m_fileListView.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.m_fileListView_ItemChecked);
            this.m_fileListView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.listView1_ItemDrag);
            this.m_fileListView.DragDrop += new System.Windows.Forms.DragEventHandler(this.listView1_DragDrop);
            this.m_fileListView.DragEnter += new System.Windows.Forms.DragEventHandler(this.listView1_DragEnter);
            // 
            // ExplorerRightPanel
            // 
            this.AllowDrop = true;
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Controls.Add(this.m_fileListView);
            this.Name = "ExplorerRightPanel";
            this.Size = new System.Drawing.Size(440, 156);
            this.ResumeLayout(false);

        }

        void m_fileListView_ItemChecked(object sender, ItemCheckedEventArgs e)
        {
            e.Item.ForeColor = e.Item.Checked ? Color.Black : Color.Gray;            
        }

        #endregion


        /// <summary>
        /// Clear all the items in the ListView panel and the internal Backup/Restore list
        /// </summary>
        public void ClearItems( )
        {
            this.m_fileListView.Items.Clear();
            if (m_panelViewMode == ViewMode.BACKUP_MODE)
            {
                m_backupList.Clear();
            }
            else if (m_panelViewMode == ViewMode.RESTORE_MODE)
            {
                m_restoreList.Clear();
            }
        }

        /// <summary>
        /// Add an item to the end of current tree.
        /// </summary>
        /// <param name="item"></param>
        public void Add(ListViewItem item,bool enabled)
        {
            m_fileListView.Items.Add(item);
            item.Checked = enabled;
            item.ForeColor = enabled ? Color.Black : Color.Gray;

            if (m_panelViewMode == ViewMode.BACKUP_MODE)
            {
                m_backupList.Add(item);
            }
            else if (m_panelViewMode == ViewMode.RESTORE_MODE)
            {
                m_restoreList.Add(item);
            }
        }

        /// <summary>
        /// Add a list of items to the end of the tree
        /// </summary>
        /// <param name="items"></param>
        public void Add(List<ListViewItem> items)
        {
            m_fileListView.Items.AddRange(items.ToArray());
            if (m_panelViewMode == ViewMode.BACKUP_MODE)
            {
                foreach (ListViewItem item in items)
                {
                    m_backupList.Add(item);
                }
            }
            else if (m_panelViewMode == ViewMode.RESTORE_MODE)
            {
                foreach (ListViewItem item in items)
                {
                    m_restoreList.Add(item);
                }
            }
        }

        public System.Windows.Forms.ListView m_fileListView;
        System.Windows.Forms.ColumnHeader FileName;
        System.Windows.Forms.ColumnHeader Extension;
        System.Windows.Forms.ColumnHeader Modified;
        System.Windows.Forms.ColumnHeader FileSize;
    }
}
